package com.hdaccp.lettingboot.controller;
import com.hdaccp.lettingboot.bean.User;
import com.hdaccp.lettingboot.util.UserUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @RequestMapping("/getUser/{id}")
    public User getUser(@PathVariable("id") int id){
        User u = null ;
        List<User> list = UserUtil.getUserList() ;
        for(User user:list){
            if(user.getId() == id){
                u = user ;
                break ;
            }
        }
        return u ;
    }
    @RequestMapping("/toIndex")
    public String toIndex(){
        System.out.println("toindex...");
        return "index" ;
    }

}
